let baseURL = "";

// const arr = document.domain.split('.')
const arr = window.location.host.split(".");
// let arr = ('chat168.xyz').split('.')
// console.log('window.location', window.location);
// console.log(' arr.slice(arr.length - 2).join(',arr, window.location );

if (process.env.NODE_ENV !== "production") {
  // baseURL = "http://stakeapi.webevil.top/"; // 内网
  baseURL = "https://api.jk66.games/"; //testing
  // baseURL = "https://api.jk181.games/"       // 正式环境
  // baseURL = "http://hallapi.lgc.com:8103"; //本地
} else {
  let url = "";
  if (arr.length >= 3) {
    if (arr[0] === "www") {
      arr[0] = "api";
      url = "api." + arr.slice(arr.length - 2).join(".");
    } else {
      url = arr[0] + "api." + arr.slice(arr.length - 2).join(".");
    }
  } else {
    arr.unshift("api");
    url = arr.slice(arr.length - 3).join(".");
  }
  baseURL = window.location.protocol + "//" + url; // 线上
}

console.log("baseURL", baseURL);

export default baseURL;
